<% content_for :css do %>
  <%= stylesheet_link_tag 'projects_index'  %>
<% end %>
<script>
    function projects_by_pay_status(pay_status)
    {
      $('pay_status').value = pay_status;
      $('payed_year').value = '';
      <%= remote_function :update => :projects,
                :url => projects_url ,
                :with => "$('projects_form').serialize()",
                :method => :get,
                :loading => short_loader('projects', :height => 500, :width => 725)
         %>
    }
    
    function payed_projects_by_payed_year(year)
    {
      $('pay_status').value = 'payed';
      $('payed_year').value = year;
      <%= remote_function :update => :projects,
                :url => projects_url ,
                :with => "$('projects_form').serialize()",
                :method => :get,
                :loading => short_loader('projects', :height => 500, :width => 725)
         %>
    }

    function work_item_types_by_stage_id(stage_id,link)
    {
      if($('stage_' + stage_id+'_work_item_types').innerHTML == '')
      {
        <%= remote_function :update => "stage_' + stage_id + '_work_item_types",
                  :url => work_item_type_stages_url,
                  :method => :get,
                  :with => "'&id=' + stage_id",
                  :loading => "$('stage_' + stage_id + '_work_item_types').show();" + short_loader("stage_' + stage_id + '_work_item_types", :height => 100, :width => 720),
                  :loaded => "$('stage_' + stage_id + '_work_item_types').hide();",
                  :complete => "show_stage(stage_id,link)"
        %>
      }
      else
      {
         show_or_hide_stage(stage_id,link);
      }
    }

    function show_stages_by_project_id_and_pay_status(project_id, pay_status)
    {
      setValue("project_" + project_id + "_" + pay_status, true);
      Effect.BlindDown('project_' + project_id +'_' + pay_status + '_stages');      
      $('project_' + project_id +'_' + pay_status + '_stages_show_button').hide();
      $('project_' + project_id +'_' + pay_status + '_stages_hide_button').show();
      $('project_' + project_id +'_' + pay_status + '_stages_show_bottom_tip').hide();
      $('project_' + project_id +'_' + pay_status + '_stages_hide_bottom_tip').show();
    }

    function hide_stages_by_project_id_and_pay_status(project_id, pay_status)
    {
      setValue("project_" + project_id + "_" + pay_status, false);
      Effect.BlindUp('project_' + project_id +'_' + pay_status + '_stages');
      $('project_' + project_id +'_' + pay_status + '_stages_show_button').show();
      $('project_' + project_id +'_' + pay_status + '_stages_hide_button').hide();      
      $('project_' + project_id +'_' + pay_status + '_stages_hide_bottom_tip').hide();
      $('project_' + project_id +'_' + pay_status + '_stages_show_bottom_tip').show();
    }
</script>
<div id="projects_stat" class="left corner">
  <%= render :file => 'projects/_index.html' %>
</div>
<div class="right corner">
  <div class="head">
    <div id="title" class="title">全部-项目</div>
    <div onmouseover = '$("project_name").className = "auto_complete_text_filed";$("search_projects").show();'
            onmouseout = '$("project_name").className = "auto_complete_text_filed_l";$("search_projects").hide();' 
            onclick='$("project_name").select();'
     >
      <%= text_field_tag :project_name, '请输入项目名后点击查询...',  
                :size => 50,
                :class => "auto_complete_text_filed_l"
         %>
      <%= link_to_remote '查询',
                :update => :projects,
                :frequency => 3,
                :url => projects_url,
                :with => "'&project_name=' + $F('project_name')",
                :method => :get,
                :loading => short_loader('projects', :height => 500, :width => 725),
                :html => {
                  :id => :search_projects,
                  :style => 'display:none',
                  :class => :base_i
                }
      %>
      <div id="projects_in_auto_complete" class="auto_complete"></div>
      <%= auto_complete_field 'project_name',
                :update => 'projects_in_auto_complete',
                :frequency => 1,
                :url => auto_complete_projects_url,
                :method => :get
         %>
    </div>
    <div class="tools">
      <div>
      <%= link_to_remote "▶创建",
                :update => :edit,
                :url => new_project_url,
                :complete => 'Effect.BlindDown("new_project")',
                :html => {
                  :class => :base
                }
       %>
      </div>
      <div id="print">
        <% if params[:pay_status] == 'paying' or params[:pay_status] == 'paused' %>
        <%= link_to "▶打印", projects_url(:pay_status => :paying, :format => :print), :target => :_blank %>
        <% end %>
      </div>
    </div>
  </div>
  <div id='edit' class="new_or_edit_project"></div>
  <div id="projects">
    <%= render :file => 'projects/index.js' %>
  </div>
  <% form_tag '#', :id => :projects_form do %>
      <%= hidden_field_tag :pay_status %>
      <%= hidden_field_tag :payed_year %>
  <% end %>
</div>
